package com.example.administrator.gaodemap;

import android.content.Context;
import android.graphics.Point;
import android.util.AttributeSet;
import android.view.MotionEvent;

import com.amap.api.maps.MapView;
import com.amap.api.maps.Projection;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.PolylineOptions;

import java.util.ArrayList;
import java.util.List;

public class MyMapView extends MapView {
    private  List<LatLng> latLngs = new ArrayList<LatLng>();
    private PolylineOptions mPolylineOptions= new PolylineOptions();

    public MyMapView(Context context) {
        super(context);
    }

    public MyMapView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public MyMapView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
//
//        if (DrawStadus.getIstance().isDrawCircle()) {
//            LatLng mapCenterPoint = getMapCenterPoint((int) event.getX(), (int) event.getY());
//            latLngs.add(mapCenterPoint);
//            Log.e("$zhw======$", "location " + mapCenterPoint.latitude + "  " + mapCenterPoint.longitude);
//            switch (event.getAction()) {
//                case MotionEvent.ACTION_DOWN:
//                    break;
//                case MotionEvent.ACTION_MOVE:
////                    getMap().addPolyline(mPolylineOptions.
////                            addAll(latLngs).width(10).color(Color.argb(255, 1, 1, 1)));
//                    getMap().addCircle(new CircleOptions().
//                center(mapCenterPoint).
//                radius(10).
//                fillColor(Color.argb(100, 1, 1, 1)).
//                strokeColor(Color.argb(100, 1, 1, 1)).
//                strokeWidth(15));
//                    latLngs.clear();
//                    break;
//                case MotionEvent.ACTION_UP:
//                    DrawStadus.getIstance().setDrawCircle(false);
//                    getMap().getUiSettings().setAllGesturesEnabled(true);
//                    break;
//                default:
//                    break;
//            }
//

//
//        }
        return super.dispatchTouchEvent(event);
    }

    public LatLng getMapCenterPoint(int x, int y) {
        Projection projection = getMap().getProjection();
        LatLng pt = projection.fromScreenLocation(new Point(x, y));
        return pt;
    }
}
